<template>
    <div class="audit_detail">
        <div class="content_panel">
            <div class="panel_list">
                <personal-info :user-data="data.personalInfo" :user-info="data.workInfo">个人信息</personal-info>
                <user-order-info :user-data="data.personalInfo">用户/订单信息</user-order-info>
                <order-list>订单列表</order-list>
                <his-tel-record :update-type="updateTableType" @updateOver="updateTable('')">历史电调情况</his-tel-record>
            </div>
        </div>
        <div class="operation_panel" v-if="checkStatus == 0">
            <tel-operation-records :user-data="data.telRecordPanel" :show-panel="showPanel" @updateTable="updateTable">
                电核记录
            </tel-operation-records>
        </div>
    </div>
</template>

<script>
    import userOrderInfo from './user-order-info';
    import hisTelRecord from './his-tel-record';
    import telOperationRecords from './tel-operation-records';
    import personalInfo from './personal-info';
    import orderList from './order-list';

    export default {
        name: 'telephone-telManage-telDetail',
        props: {
            showPanel: {
                type: Boolean,
                default: true
            }
        },
        components: {
            userOrderInfo,
            hisTelRecord,
            telOperationRecords,
            personalInfo,
            orderList,
        },
        data() {
            return {
                checkStatus: this.$route.params.checkStatus,
                userId: this.$storage.get('userId'),
                locale: this.$storage.get('locale'),
                orderId: this.$storage.get('orderNid'),
                updateTableType: '',
                data: {
                    personalInfo: {
                        shengXiao: '',
                        account: '',
                        bankName: '',
                        realName: '',
                        cardId: '',
                        age: '',
                        phone: '',
                        sex: '',
                        province: '',
                        city: '',
                        district: '',
                        address: '',
                        contactFirst: '',
                        relationshipFirst: '',
                        phoneFirst: '',
                        contactSecond: '',
                        relationshipSecond: '',
                        phoneSecond: '',
                        contactThird: '',
                        relationshipThird: '',
                        phoneThird: '',
                        contactFourth: '',
                        relationshipFourth: '',
                        phoneFourth: '',
                        accountPhone: '',
                        userId: '',
                        bankAccount: '',
                        companyName: '',
                    },
                    workInfo: {
                        address: '',
                        city: '',
                        companyName: '',
                        district: '',
                        province: '',
                        companyTel: '',
                    },
                    telRecordPanel: {
                        phone: '',
                    }
                },
                product: '', // 渠道
            };
        },
        methods: {
            getUserInfo() {
                // 获取用户信息
                const params = {
                    orderId: this.orderId,
                    id: this.userId,
                    product: this.product,
                };
                this.$api.customer.findUserInfo(params).then((res) => {
                    const {status, data, error} = res;
                    if (status === '1' && error === '00000000') {
                        const {
                            userBaseInfo,
                            userCardInfo,
                            userInfo,
                            userContactsInfo,
                            accountInfo,
                            userAccountInfo,
                            userJobInfo
                        } = data;
                        this.mergeData(this.data.personalInfo, userCardInfo);
                        this.mergeData(this.data.personalInfo, userBaseInfo);
                        this.mergeData(this.data.personalInfo, userInfo);
                        this.mergeData(this.data.personalInfo, userCardInfo);
                        this.mergeData(this.data.personalInfo, accountInfo);
                        this.mergeData(this.data.personalInfo, userContactsInfo);
                        this.mergeData(this.data.personalInfo, userAccountInfo);
                        this.mergeData(this.data.telRecordPanel, userInfo);
                        this.mergeData(this.data.personalInfo, userJobInfo);
                        this.mergeData(this.data.workInfo, userJobInfo);
                    }
                });
            },
            mergeData(target, source) {
                // 合并数据
                if (!source || typeof source !== 'object') {
                    return;
                }
                Object.keys(target).forEach((key) => {
                    if (!target[key] && source[key]) {
                        target[key] = source[key];
                    }
                });
            },
            updateTable(val) {
                this.updateTableType = val;
            }
        },
        created() {
            const params = this.$route.params;
            this.product = params.addProduct;
            if (this.$route.params.userId) {
                this.userId = this.$route.params.userId;
                this.orderId = this.$route.params.orderNid;
                this.getUserInfo();
            }
        }
    };
</script>
<style lang="scss">
    @import "~@/assets/scss/function";
    [data-page=telephone-telManage-telDetail] {
        .tel-personal-info {
            margin-left: 30px;
            margin-top: 5px;
        }
        .tel-personal-info .row.el-row {
            padding: 3px;
        }
        .para_top {
            display: inline-block;
            padding-top: 10px;
        }
        .userBankNum {
            margin-left: 150px;
        }
        .left_menu {
            display: none;
        }
        .el-col.el-col-24 {
            line-height: 25px;
        }
        .el-tooltip__popper {
            max-width: 300px;
            word-break: break-all;
            background-color: #fff;
            box-shadow: 0px 0px 5px #ccc;
            color: #000;
        }
        .telPagination {
            padding-bottom: 20px;
            float: right;
        }
        .opacity_panel {
            opacity: 0.7;
        }
        .detail_module_panel {
            padding: 0 12px;
        }
        .detail_panel_title_icon {
            background-repeat: no-repeat;
            background-position: left center;
            background-size: 20px 20px;
        }
        .detail_panel_title {
            padding-left: 32px;
            margin: 0;
            font-size: 14px;
            height: 52px;
            line-height: 52px;
            border-bottom: 1px solid $colorSplit;
        }
        .panel_info_content {
            padding: 20px 0;
            .row {
                margin-bottom: 12px;
                &:last-child {
                    margin-bottom: 0;
                }
            }
            .label {
                color: #a6a8aa;
                font-size: 12px;
                text-align: right;
                padding: 0 8px;
            }
            .info {
                font-size: 12px;
                padding: 0 8px;
            }
            .imgs {
                li {
                    display: inline-block;
                    width: 200px;
                    margin-right: 24px;
                    border: 1px solid $colorSplit;
                    border-radius: 8px;
                    overflow: hidden;
                    a {
                        display: block;
                        height: 112px;
                        width: 100%;
                        background-color: #e5e5e5;
                        background-repeat: no-repeat;
                        background-position: center center;
                        background-size: cover;
                    }
                    .img_desc {
                        height: 32px;
                        line-height: 32px;
                        padding: 0 16px;
                    }
                }
            }
        }
        .panel_info_content_title {
            color: #5e6061;
            font-size: 14px;
            .dot {
                display: inline-block;
                width: 5px;
                height: 5px;
                border-radius: 50%;
                background-color: #5e6061;
                margin-right: 10px;
                margin-bottom: 2px;
            }
        }
        // 历史贷款信息列表
        .loan_history_table {
            th {
                background-color: #f4f5f6;
            }
        }
        // 个人信息icon
        .personal_info_icon {
            background-image: url("~@/assets/img/icon_personal_info.png");
        }
        // 工作/学生信息icon
        .work_student_icon {
            background-image: url("~@/assets/img/icon_work_student.png");
        }
        // 材料信息icon
        .other_info_icon {
            background-image: url("~@/assets/img/icon_other_info.png");
        }
        // 联系人icon
        .contacts_icon {
            background-image: url("~@/assets/img/icon_contacts.png");
        }
        // 操作面板
        .el-select {
            width: 100%;
        }
        .el-form-item__label {
            font-size: 12px;
            line-height: 17px;
            color: #a6a8aa;
            padding-bottom: 8px;
        }
        .el-form-item {
            margin-bottom: 16px;
        }
        .el-button--mini {
            padding: 5px 10px;
        }
        .info.contact.el-col.el-col-16 {
            text-align: center;
        }
        .el-form-item__content {
            line-height: 23px;
        }
    }
</style>
<style lang="scss" scoped>
    @import "~@/assets/scss/function";

    .audit_detail {
        display: flex;
        height: 100%;
        width: 100%;
    }

    .content_panel {
        flex: 1;
        padding: 16px 16px 0;
        display: flex;
        flex-direction: column;
        position: relative;
        overflow: hidden;
    }

    .operation_panel {
        width: 360px;
        background-color: #fff;
        /*padding: 16px;*/
        overflow: auto;
        box-shadow: -1px 0 4px 0 rgba(0, 0, 0, 0.05);
    }

    .panel_list {
        background-color: #fff;
        flex: 1;
        overflow: auto;
    }

    .placeholder {
        height: 212px;
        position: relative;
        margin: 0 -16px 0;
        overflow: visible;
    }

    .tables {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        background-color: $colorBg;
        height: 500px;
    }

    .tabs {
        background-color: $primary;
        position: relative;
        li {
            display: inline-block;
            a {
                color: rgba(255, 255, 255, 0.6);
                display: block;
                padding: 0 24px;
                height: 44px;
                line-height: 44px;
                position: relative;
                &.active {
                    color: #fff;
                    .detail_menu_icon {
                        display: block;
                    }
                }
                .detail_menu_icon {
                    display: none;
                    position: absolute;
                    bottom: -7px;
                    left: 50%;
                    transform: translateX(-50%);
                    font-size: 20px;
                    color: #f4f5f6;
                }
            }
        }
        .detail_tables_icon, .hide_tables_icon {
            position: absolute;
            top: 0;
            right: 0;
            height: 44px;
            line-height: 44px;
            width: 56px;
            color: #fff;
            font-size: 25px;
            cursor: pointer;
            text-align: center;
            &.rotate {
                transform: rotate(180deg);
            }
        }
        .hide_tables_icon {
            right: 70px;
        }
    }
</style>
